import Vue from "vue"
import Vuex from "vuex"

Vue.use(Vuex)


const store = new Vuex.Store({
  state: {
    goodsbuyList: []
  },
  mutations: {
    addbuyCar(state,e){
		let islist = state.goodsbuyList.find(item =>  item.id===e.id)
		console.log(islist)
		if(islist){
			islist.count += 1 //从find里找到的相同数组，可以替代原数组使用，所以islist.count+1等于goodsbuyList[n].count+1
		}else{
			e.count = 1
			e.ischeck = false
			state.goodsbuyList.push(e)
		}
	}
  }
})

export default store